package org.jc.subject.domain.convert;

import org.jc.subject.domain.entity.SubjectCategoryBO;
import org.jc.subject.domain.entity.SubjectLabelBO;
import org.jc.subject.infra.basic.entity.SubjectCategory;
import org.jc.subject.infra.basic.entity.SubjectLabel;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 功能描述
 *
 * @author wanghongqian
 * @date 2024/06/17 14:47
 */
@Mapper
public interface SubjectLabelConverter {

    SubjectLabelConverter INSTANCE = Mappers.getMapper(SubjectLabelConverter.class);

    SubjectLabel convertBOToLabel(SubjectLabelBO subjectLabelBO);

//    @IterableMapping(elementTargetType = SubjectLabelBO.class)
    @Mapping(target = "categoryId",ignore = true)
    List<SubjectLabelBO> convertLabelsToBos(List<SubjectLabel> subjectLabels,@Context Long categoryId);

    @AfterMapping
    default void setCategoryId(@MappingTarget SubjectLabelBO subjectLabelBO, @Context Long categoryId) {
        subjectLabelBO.setCategoryId(categoryId);
    }

}
